import request from '@/utils/request'
// 归档记录 API接口
const archiveApi = {
    saveArchive: '/apl_archive/save',  // 保存归档记录
    getArchiveByApplyid: '/apl_archive/getArchiveByApplyid', // 通过applyid查询对应的归档记录
    getDocTreeByApplyid : '/apl_dossier/getDocTreeByApplyid', // 通过applyid查询对应的电子卷宗的树层级结构
    deleteTreeNode: '/apl_dossier/deleteTreeNode', //删除树层级节点数据，删除全部的子层级文件
    addTreeNode: '/apl_dossier/addTreeNode', //新增层级节点数据，
    updateTreeNodeName: '/apl_dossier/updateTreeNodeName', //更新节点名称
    addRootTreeNode: '/apl_dossier/addRootTreeNode', //根节点保存
    saveMaterialToTree: '/apl_dossier/saveMaterialToTree', //保存材料文件到对应的树节点
    saveNoStoreMaterialToTree: '/apl_dossier/saveNoStoreMaterialToTree', // 上传新文件保存到对应的树节点
    queryLastTaskidByInstid: '/flow/queryLastTaskidByInstid', // 查询流程实例id processinstanceid
    getAdmirePersonInfo: '/apl_admreview/getAdmirePersonInfo', //获取当前applyid的第三人和受理人信息
    updateTreeNodeIndex: '/apl_dossier/updateTreeNodeIndex', //重新更新目录页码序号
    recordCase: '/apl_dossier/recordCase', //案件归档接口
}

/**
 * 按照applyid查询归档记录
 * @param {*} params 
 * @returns 
 */
export function getArchiveByApplyid(params) {
    return request({
        url: archiveApi.getArchiveByApplyid,
        method: 'post',
        params: params
    })
}


/**
 * 保存归档记录
 * @param {*} body 
 * @returns 
 */
export function saveArchive(body) {
    return request({
        url: archiveApi.saveArchive,
        method: 'post',
        data: body
    })
}



/**
 * 通过applyid查询对应的电子卷宗的树层级结构
 * @param {*} params 
 * @returns 
 */
export function getDocTreeByApplyid(params) {
    return request({
        url: archiveApi.getDocTreeByApplyid,
        method: 'post',
        params: params
    })
}


/**
 * 删除树层级节点
 * @param {*} params 
 * @returns 
 */
export function deleteTreeNode(params) {
    return request({
        url: archiveApi.deleteTreeNode,
        method: 'post',
        params: params
    })
}

/**
 * 新增层级节点数据
 * @param {*} params 
 * @returns 
 */
export function addTreeNode(params) {
    return request({
        url: archiveApi.addTreeNode,
        method: 'post',
        params: params
    })
}

/**
 * 根节点保存
 * @param {} params 
 * @returns 
 */
export function addRootTreeNode(params) {
    return request({
        url: archiveApi.addRootTreeNode,
        method: 'post',
        params: params
    })
}

/**
 * //更新节点名称
 * @param {*} params 
 * @returns 
 */
export function updateTreeNodeName(params) {
    return request({
        url: archiveApi.updateTreeNodeName,
        method: 'post',
        params: params
    })
}

/**
 * 保存材料文件到对应的树节点
 * @param {*} params 
 * @returns 
 */
export function saveMaterialToTree(params) {
    return request({
        url: archiveApi.saveMaterialToTree,
        method: 'post',
        params: params
    })
}

/**
 * 上传新文件保存到对应的树节点
 * @param {*} params 
 * @returns 
 */
export function saveNoStoreMaterialToTree(params, fileList) {
    var body = new FormData()
    if (fileList != undefined && fileList.length > 0) {
      fileList.forEach(item => {
          body.append('files', item)
      })
      return request({
        url: archiveApi.saveNoStoreMaterialToTree,
        headers: {"Conten-Type": "mulitpart/form-data"},
        method: 'post',
        params: params,
        data: body
      })
    }
}


/**
 * 查询流程实例id processinstanceid
 */
export function queryLastTaskidByInstid(params) {
    return request({
        url: archiveApi.queryLastTaskidByInstid,
        method: 'post',
        params: params
    })
}

/**
 * 获取当前applyid的第三人和受理人信息
 */
export function getAdmirePersonInfo(params) {
    return request({
        url: archiveApi.getAdmirePersonInfo,
        method: 'post',
        params: params
    })
}

/**
 * 重新更新目录页码序号
 * @param {*} params 
 * @returns 
 */
export function updateTreeNodeIndex(params) {
    return request({
        url: archiveApi.updateTreeNodeIndex,
        method: 'post',
        params: params
    })
}


/**
 * 案件归档
 * @param {} params 
 * @returns 
 */
export function recordCase(params) {
    return request({
        url: archiveApi.recordCase,
        method: 'post',
        params: params
    })
}